package com.fwc.churchtracker.domo;

import com.fwc.fw.annotation.Form;
import com.fwc.fw.annotation.FormField;
import com.fwc.fw.annotation.LookupDomo;
import com.fwc.fw.annotation.LookupField;
import com.fwc.fw.domo.AbstractPersistableDomo;

import javax.jdo.annotations.Discriminator;
import javax.jdo.annotations.DiscriminatorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.Unique;

@LookupDomo(filter="active==true")
@Form(label="Player")
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
@Inheritance(strategy=InheritanceStrategy.NEW_TABLE)
@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME)
public class Member extends AbstractPersistableDomo {

	@FormField(label="Last Name", order=20)
    @Persistent
    private String lastName;

	@LookupField
    @Persistent
    private String _ci_lastName;

    @FormField(label="First Name", order=10)
    @Persistent
    private String firstName;

	@LookupField
    @Persistent
    private String _ci_firstName;

    @FormField(label="EMail", order=30)
    @Persistent
    @Unique(name="UNIQUE_EMAIL_IDX")
    private String email;

    @FormField(label="Phone #", order=40)
    @Persistent
    private String phone;

    @FormField(label="Active", order=50)
    @Persistent
    private Boolean active=true;

    @Persistent
    @Unique(name="UNIQUE_ACCOUNTID_IDX")
    private String accountId;

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
    	if(firstName!=null) {
    		this._ci_firstName = firstName.toLowerCase();
    	} else this._ci_firstName = null;
		this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
    	if(lastName!=null) {
    		this._ci_lastName = lastName.toLowerCase();
    	} else this._ci_lastName = null;
        this.lastName = lastName;
    }

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public String toString() {
		return this.firstName + " " + this.lastName;
	}

	public Boolean getActive() {
		return active;
	}

	public void setActive(Boolean active) {
		this.active = active;
	}

	public String getAccountId() {
		return accountId;
	}

	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}
	
}